package exactSearch;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.StringTokenizer;


public class UniqueEntities {

	public static void main(String []args) throws IOException{
		ArrayList <String> al=new ArrayList<String>();
		ArrayList <String> ml=new ArrayList<String>();
		PrintStream ps=new PrintStream("J:\\BC3_IMT_Training\\training.txt");
		FileReader fr=new FileReader("J:\\BC3_IMT_Training\\annotations\\IMT_training_annotations.txt");
		BufferedReader fbr=new BufferedReader(fr);
		String str=fbr.readLine();
		int c=0;
		while(str!=null){
			
			StringTokenizer st=new StringTokenizer(str);
			while(st.hasMoreTokens()){
				String pmid=st.nextToken();
				String mi=st.nextToken();
				if(!al.contains(pmid)){
					ps.print("\t"+c);
					ml=new ArrayList<String>();
					al.add(pmid);
					c=0;
					ps.println();
				ps.print(pmid+"\t");
				}
				if(!ml.contains(mi)){
					c++;
				
					ml.add(mi);
					ps.print(mi+" ");	
				}

			}
			//ps.print("\t\t");
			str=fbr.readLine();
					
			
		}
		

	}
}
